import java.util.Scanner;

//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
    public static int count = 0;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        char a = 'A', b = 'B', c = 'C';
        hanio(n, a, b, c);
        System.out.println("移动了" + count + "次");
    }
    public static void hanio(int n, char a, char b, char c){
        count++;
        if(n == 1){
            move(n, a, c);
        }else{
            hanio(n - 1, a, c, b);
            move(n, a, c);
            hanio(n - 1, b, a, c);
        }
    }
    public static void move(int n, char a, char c){
        System.out.println("move " + n + " from " + a +" to " + c );
    }
}